package universityModel.lesson;

import universityModel.curriculum.WeekDays;
import universityModel.person.Name;
import universityModel.utils.ArrayModel;

/**
 *
 * @author Parkhomenko Dmytro
 */

abstract public class Lesson implements LessonInterface {
    protected Name teacher;
    protected ArrayModel<String> groups = new ArrayModel<String>();
    private Time numPair;
    private Venue venue;
    private String subject;
    private WeekDays weekDay;

    public Lesson(Name teacher,  
                  Time numPair, 
                  Venue venue, 
                  String subject, 
                  WeekDays weekDay) {
        this.teacher = teacher;
        this.numPair = numPair;
        this.venue = venue;
        this.subject = subject;
        this.weekDay = weekDay;
    }
           
    public void setGroup(String name) {
        groups.add(name);
    }
    
    public void add(String group) {
        groups.add(group);
    }

    public ArrayModel<String> getGroups() {
        return new ArrayModel<String>(groups);
    }
       
    public void setTeacher(Name teacher) {
	this.teacher = teacher;
    }

    public void setTime(Time time) {
        this.numPair = time;
    }

    public void setVenue(Venue venue) {
        this.venue = venue;
    }

    public Time getNumPair() {
        return numPair;
    }

    public int getWeekDay() {
        return weekDay.getDay();
    }
    
    public boolean isGroup(String name) {
        for(int index = 0; index < groups.size(); index++) {
            if(groups.get(index).equals(name)) {
                return true;
            }
        }
        return false;
    }
    
    @Override
    public String toString() {
        StringBuilder  builder = new StringBuilder();
        
        builder.append(subject);
        builder.append("\n");
        builder.append(teacher);
        builder.append("\n");
        builder.append(venue.toString());
        builder.append("\n");
        builder.append(numPair);
        
        return builder.toString();
    }
}